package leducHoldem.Data;

import java.io.Serializable;

public class Move implements Serializable {

	private static final long serialVersionUID = 1L;

	public String action = "";
	public byte value = 0;

	public Move(String action) {
		this.action = action;
		
		if(action.equals("J")) {
			value = 1;
		}
		if(action.equals("Q")) {
			value = 2;
		}
		if(action.equals("K")) {
			value = 3;
		}
	}

	public Move(byte value) {
		
		this.value = value;
		
		switch (value) {
		case 1:
			this.action = "J";
			break;
		case 2:
			this.action = "Q";
			break;
		case 3:
			this.action = "K";
			break;
		default:
			this.action = null;
		}
	}

	public Move(Move move) {
		this.action = move.action;
		this.value = move.value;
	}


	@Override
	public int hashCode() {
		
		final int prime = 31;
		int result = 1;
		
		result = prime * result + ((action == null) ? 0 : action.hashCode());
		result = prime * result + value;
		
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		
		Move other = (Move) obj;
		
		if (action == null) {
			if (other.action != null)
				return false;
		} else if (!action.equals(other.action))
			return false;
		
		if (value != other.value)
			return false;
		
		return true;
	}

	public String toString() {
		return action;
	}

}
